/*   1:    */ package org.intellij.plugins.relaxNG.model.descriptors;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.Pair;
import gnu.trove.THashMap;
import org.kohsuke.rngom.digested.*;

import javax.xml.namespace.QName;
import java.util.LinkedHashMap;
import java.util.Map;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */ 
/*  18:    */ class AttributeFinder
/*  19:    */   extends RecursionSaveWalker
/*  20:    */ {
/*  21:    */   private int c;
/*  22:    */   private int d;
/*  23:    */   private final QName e;
/*  24: 36 */   private final Map<DAttributePattern, Pair<? extends Map<String, String>, Boolean>> f = new THashMap();
/*  25:    */   private DAttributePattern g;
/*  26:    */   
/*  27:    */   private AttributeFinder()
/*  28:    */   {
/*  29: 41 */     this.e = null;
/*  30: 42 */     this.d += 1;
/*  31:    */   }
/*  32:    */   
/*  33:    */   private AttributeFinder(QName paramQName)
/*  34:    */   {
/*  35: 46 */     this.e = paramQName;
/*  36:    */   }
/*  37:    */   
/*  38:    */   public Void onElement(DElementPattern paramDElementPattern)
/*  39:    */   {
/*  40: 50 */     this.c += 1;
/*  41:    */     try
/*  42:    */     {
/*  43: 52 */       this.g = null;
/*  44:    */       Void localVoid;
/*  45: 53 */       if (this.c < 2) {
/*  46: 54 */         return super.onElement(paramDElementPattern);
/*  47:    */       }
/*  48: 56 */       return null;
/*  49:    */     }
/*  50:    */     finally
/*  51:    */     {
/*  52: 58 */       this.c -= 1;
/*  53:    */     }
/*  54:    */   }
/*  55:    */   
/*  56:    */   public Void onAttribute(DAttributePattern paramDAttributePattern)
/*  57:    */   {
/*  58: 63 */     assert (this.c > 0);
/*  59: 65 */     if ((this.c == 1) && ((this.e == null) || (paramDAttributePattern.getName().contains(this.e))))
/*  60:    */     {
/*  61: 66 */       this.g = paramDAttributePattern;
/*  62: 67 */       this.f.put(paramDAttributePattern, Pair.create(new LinkedHashMap(), Boolean.valueOf(this.d > 0)));
/*  63: 68 */       return super.onAttribute(paramDAttributePattern);
/*  64:    */     }
/*  65: 70 */     return null;
/*  66:    */   }
/*  67:    */   
/*  68:    */   public Void onValue(DValuePattern paramDValuePattern)
/*  69:    */   {
/*  70: 74 */     if (this.g != null) {
/*  71: 75 */       ((Map)((Pair)this.f.get(this.g)).first).put(paramDValuePattern.getValue(), paramDValuePattern.getType());
/*  72:    */     }
/*  73: 77 */     return super.onValue(paramDValuePattern);
/*  74:    */   }
/*  75:    */   
/*  76:    */   public Void onOptional(DOptionalPattern paramDOptionalPattern)
/*  77:    */   {
/*  78: 81 */     this.d += 1;
/*  79:    */     try
/*  80:    */     {
/*  81: 83 */       return super.onOptional(paramDOptionalPattern);
/*  82:    */     }
/*  83:    */     finally
/*  84:    */     {
/*  85: 85 */       this.d -= 1;
/*  86:    */     }
/*  87:    */   }
/*  88:    */   
/*  89:    */   public Void onZeroOrMore(DZeroOrMorePattern paramDZeroOrMorePattern)
/*  90:    */   {
/*  91: 90 */     this.d += 1;
/*  92:    */     try
/*  93:    */     {
/*  94: 92 */       return super.onZeroOrMore(paramDZeroOrMorePattern);
/*  95:    */     }
/*  96:    */     finally
/*  97:    */     {
/*  98: 94 */       this.d -= 1;
/*  99:    */     }
/* 100:    */   }
/* 101:    */   
/* 102:    */   public Void onChoice(DChoicePattern paramDChoicePattern)
/* 103:    */   {
/* 104: 99 */     this.d += 1;
/* 105:    */     try
/* 106:    */     {
/* 107:101 */       return super.onChoice(paramDChoicePattern);
/* 108:    */     }
/* 109:    */     finally
/* 110:    */     {
/* 111:103 */       this.d -= 1;
/* 112:    */     }
/* 113:    */   }
/* 114:    */   
/* 115:    */   public Void onData(DDataPattern paramDDataPattern)
/* 116:    */   {
/* 117:108 */     if ((this.c == 1) && (this.g != null)) {
/* 118:109 */       ((Map)((Pair)this.f.get(this.g)).first).put(null, paramDDataPattern.getType());
/* 119:    */     }
/* 120:111 */     return null;
/* 121:    */   }
/* 122:    */   
/* 123:    */   public static Map<DAttributePattern, Pair<? extends Map<String, String>, Boolean>> find(QName paramQName, DPattern... paramVarArgs)
/* 124:    */   {
/* 125:115 */     AttributeFinder localAttributeFinder = new AttributeFinder(paramQName);
/* 126:116 */     localAttributeFinder.doAccept(paramVarArgs);
/* 127:117 */     return localAttributeFinder.f;
/* 128:    */   }
/* 129:    */   
/* 130:    */   public static Map<DAttributePattern, Pair<? extends Map<String, String>, Boolean>> find(DPattern... paramVarArgs)
/* 131:    */   {
/* 132:121 */     AttributeFinder localAttributeFinder = new AttributeFinder();
/* 133:122 */     localAttributeFinder.doAccept(paramVarArgs);
/* 134:123 */     return localAttributeFinder.f;
/* 135:    */   }
/* 136:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.model.descriptors.AttributeFinder

 * JD-Core Version:    0.7.0.1

 */